var pageFun = {
	/** 返回上一页 */
	goBack : function() {
		window.history.back();
	},

	/** 发送ajax请求 */
	ajaxRequest : function(url, params, callback) {
		$.ajax({
					type : 'POST',
					url : url,
					data : params,

					cache : false,
					success : callback
				});
	},
	/** 发送ajax请求 */
	ajaxJsonRequest : function(url, params, callback) {
		$.ajax({
					type : 'post',
					dataType : "json",
					url : url,
					data : params,
					cache : false,
					success : callback
				});
	},

	/** 异步提交表单 */
	ajaxSubmitForm : function(formId, url, callback) {
		$.ajax({
					type : 'POST',
					url : url,
					cache : false,
					data : $('#' + formId).serialize(),
					success : callback
				});
	},

	/**
	 * 打开页面弹出框(注意请不要用width,height,modal,autoDiyParem做为后台参数传递)
	 * 
	 * @param title
	 *            弹出框标题
	 * @param url
	 *            请求地址
	 * @param width
	 *            宽度 不传默认为550
	 * @param height
	 *            高度 不传默认为 750;
	 * @param noshowTitle
	 *            是否显示弹出框头 默认显示
	 * @param paramObj
	 *            请求参数 格式如：{a:1,b:2}
	 */
	openThickBox : function(title, url, width, height, noshowTitle, paramObj) {
		var param = "";
		for (var obj in paramObj) {
			param += obj + "=" + paramObj[obj] + "&";
		}
		param = "&" + param.substring(0, param.lastIndexOf("&"));

		var diyParam = param.replace(new RegExp(" ", "gm"), "").replace(
				new RegExp("&", "gm"), "|").replace(new RegExp("=", "gm"), "_");
		if (diyParam != '') {
			param = param + "&autoDiyParem=" + (diyParam || "");
		}
		url = url || "";
		var index_url = url.indexOf("?");
		if (-1 == index_url) {
			url = url + "?";
		}
		width = width || 750;
		height = height || 550;
		tb_show(title, url + encodeURI(encodeURI(param))
						+ "&TB_iframe=true&width=" + width + "&height="
						+ height + "&modal=" + noshowTitle, false);
		// window.top.tb_show(title,url+encodeURI(encodeURI(param))+"&TB_iframe=true&width="+width+"&height="+height+"&modal="+noshowTitle,false);
	},

	closeThickBox : function() {
		self.parent.tb_remove();
	},

	/**
	 * (增，删，改)返回列表页查询参数保存方法
	 * 
	 * @param url
	 *            当前请求的url
	 * @param formId
	 *            查询表单ID
	 * @param page_No
	 *            当前页码
	 */
	refererLink : function(url, formId, page_No) {

		var linkForm = $("<form action='" + url + "' method='post'></form>");
		$(linkForm)
				.append("<input type='hidden' name='referer_record' value='1'/>");

		// 当前页面请求的URL
		var locatinUrl = location.href;
		$(linkForm).append("<input type='hidden' name='referer_url' value='"
				+ locatinUrl + "'/>");

		if (page_No && page_No != "") {
			$(linkForm)
					.append("<input type='hidden' name='referer_pageNo' value='"
							+ page_No + "'/>");
		}

		if (formId && formId != "") {
			var queryParam = $('#' + formId).serialize();
			$(linkForm)
					.append("<input type='hidden' name='referer_params' value='"
							+ queryParam + "'/>");
		}

		$("body").append($(linkForm));
		$(linkForm).submit();
	},

	/**
	 * (增，删，改)返回列表页查询参数保存方法
	 * 
	 * @param url
	 *            当前请求的url
	 * @param formId
	 *            查询表单ID
	 * @param page_No
	 *            当前页码
	 */
	refererFormLink : function(url, formId, page_No) {

		var linkForm = $("<form action='" + url
				+ "' method='post' target='_blank'></form>");
		$(linkForm)
				.append("<input type='hidden' name='referer_record' value='1'/>");

		// 当前页面请求的URL
		var locatinUrl = location.href;
		$(linkForm).append("<input type='hidden' name='referer_url' value='"
				+ locatinUrl + "'/>");

		if (page_No && page_No != "") {
			$(linkForm)
					.append("<input type='hidden' name='referer_pageNo' value='"
							+ page_No + "'/>");
		}

		if (formId && formId != "") {
			var queryParam = $('#' + formId).serialize();
			$(linkForm)
					.append("<input type='hidden' name='referer_params' value='"
							+ queryParam + "'/>");
		}

		$("body").append($(linkForm));
		$(linkForm).submit();
	},

	/**
	 * 添加到收藏夹
	 * 
	 * @param title
	 *            收藏夹名称
	 * @param url
	 *            地址
	 * @returns {Boolean}
	 */
	addFavorite : function(title, url) {
		title = title || document.title;
		url = url || location.href;
		if (window.sidebar) {
			window.sidebar.addPanel(title, url, '');
		} else if (window.external) {
			window.external.addFavorite(url, title);
		}
	},

	/**
	 * 打开设为主页对话框。
	 * 
	 * @param {String}
	 *            url 地址。
	 * @return {Boolean} 是否成功。
	 */
	setHomepage : function(url) {
		url = url || location.href;
		if (navigator.isIE) {
			document.body.style.behavior = "url(#default#homepage)";
			document.body.setHomePage(url);
		} else if (navigator.isFirefox) {
			if (window.netscape) {
				try {
					netscape.security.PrivilegeManager
							.enablePrivilege("UniversalXPConnect"); // 解决执行命令的问题
				} catch (e) {
					trace
							.error("您使用的FireFox浏览器安全设置过高,以至于影响程序的正常响应！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
				}
			}
			Components.classes["@mozilla.org/preferences-service;1"]
					.getService(Components.interfaces.nsIPrefBranch)
					.setCharPref("browser.startup.homepage", url);
		}
	},
	/**
	 * Json获取日期格式
	 * 
	 * @param jSonDate
	 * @returns {String}
	 */
	getDate4JSon : function(date) {
		var year = date.year + 1900;
		var month = date.month + 1;
		var day = date.date;
		return year + "-" + month + "-" + day;
	},

	/**
	 * Json获取时间格式
	 * 
	 * @param jSonDate
	 * @returns {String}
	 */
	getDateTime4JSon : function(date) {
		var year = date.year + 1900;
		var month = date.month + 1;
		var day = date.date;
		var hh = date.hours;
		var mm = date.minutes;
		var ss = date.seconds;
		return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
	},

	/* 获取日期格式 */
	getDate : function(date) {
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();
		return year + "-" + month + "-" + day;
	},

	/* 获取日期时间格式 */
	getDateTime : function(date) {
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();
		var hh = date.getHours();
		var mm = date.getMinutes();
		var ss = date.getSeconds();
		return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
	},

	/**
	 * 分页组件
	 * 
	 * @param id
	 *            表单ID
	 * @param count
	 *            分页总数
	 * @param start
	 *            开始页数
	 * @param display
	 *            显示条数
	 * @param clickEvent
	 *            触发事件
	 */
	paginate : function callPaginate(id, count, start, display, clickEvent) {
		$("#" + id).paginate({
					count : count,
					start : start,
					display : display,
					border : false,
					text_color : '#000000',
					background_color : 'none',
					text_hover_color : '#FF0000',
					background_hover_color : 'none',
					images : false,
					mouse : 'press',
					onClick : clickEvent
				});
	},

	parentiframeHandle : function(iframeId) {
		return window.parent.frames[iframeId].parent;
	},

	jumpRequest : function(url) {
		window.location.href = url;
	}

};
